package com.wkck.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wkck.domain.Delivered_Library;
import com.wkck.domain.Job;
import com.wkck.domain.JobAndJoin;
import com.wkck.domain.Resume;
import com.wkck.domain.PieChartInfoDto;
import com.wkck.mapper.JobMapper;
import com.wkck.service.JobService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobService {

    @Resource
    private JobMapper jobMapper;

    /**
     * 返回简易信息
     * @return
     */

    @Override
    public List<Job> getEasyMsg() {
        return jobMapper.getEasyMsg();
    }

    /**
     * 无参数查询简易信息
     * @param currentPage
     * @param pageSize
     * @return
     */

    @Override
    public IPage<Job> getPage(int currentPage, int pageSize) {
        IPage<Job> page = new Page<>(currentPage,pageSize);
        return jobMapper.selectPage(page,null);
    }

    /**
     * 模糊查询简易信息
     * @param currentPage
     * @param pageSize
     * @param job
     * @return
     */

    @Override
    public IPage<Job> getPageAndParams(int currentPage, int pageSize, Job job) {
        LambdaQueryWrapper<Job> lqw = new LambdaQueryWrapper<>();
        lqw.like(Strings.isNotEmpty(job.getJob_name()),Job::getJob_name,job.getJob_name());
        lqw.like(Strings.isNotEmpty(job.getJob_address()),Job::getJob_address,job.getJob_address());
        lqw.like(Strings.isNotEmpty(job.getJob_type()),Job::getJob_type,job.getJob_type());
        IPage<Job> page = new Page<>(currentPage,pageSize);
        page = jobMapper.selectPage(page,lqw);
        return page;
    }

    /**
     * 根据id来进行查询信息
     * @param id
     * @return
     */

    @Override
    public JobAndJoin getAll(Integer id) {
        return jobMapper.getAll(id);
    }

    /**
     * 通过用户id来判断是否有简历信息
     * @param id
     * @return
     */

    @Override
    public Resume getResumeByUserId(Integer id) {
        return jobMapper.getResumeByUserId(id);
    }

    /**
     * 投递简历
     * @param job_join_id
     * @param user_id
     * @param resume_id
     * @return
     */

    @Override
    public int insertSendResumeMessage(Integer job_join_id, Integer user_id, Integer resume_id) {
        return jobMapper.insertSendResumeMessage(job_join_id,user_id,resume_id);
    }

    /**
     * 投递建立前判断该用户投递简历到该公司的简历状态
     * @param job_join_id
     * @param user_id
     * @param resume_id
     * @return
     */

    @Override
    public Delivered_Library selectResumeAndCompany(Integer job_join_id, Integer user_id, Integer resume_id) {
        return jobMapper.selectResumeAndCompany(job_join_id,user_id,resume_id);
    }

    @Override
    public Integer job_joinCount() {
        return jobMapper.job_joinCount();
    }

    @Override
    public List<PieChartInfoDto> getJobAddressInfo() {
        return jobMapper.getJobAddressInfo();
    }

    @Override
    public Integer countJobLock() {
        return jobMapper.countJobLock();
    }

    @Override
    public List<String> getCities() {
        return jobMapper.getCities();
    }

}
